varnish的VCL的配置详解
}
obj.lastuse 对象上次访问的大致时间
return (pipe);
"Host: "
}
}
进入到pass模式
director b2 random {
.initial = 3;
.probe = {
vcl_error
.first_byte_timeout = 5s; 连接上后等待接受第一个字节的时间
复制代码 代码如下:
返回值可以为:# NB: rn automatically inserted after each string!
req.proto client使用的HTTP协议版本
obj.ttl 对象还能存活的时间。
set req.grace = 2m;
req.url 请求的URL
beresp.ttl 目标在cache中存活时间 The DNS director
可以调用一下参数终止该函数
Deliver the error object to the client.
It is also possible to specify the raw HTTP request:
resp.status 将被返回的HTTP协议状态码{
lookup
beresp.proto 源数据库使用的HTTP协议。
切换到pipe模式,调用vcl_ pipe函数。
pass
复制代码 代码如下:
.host = "fs2";restart
.suffix = "internal.example.net"; 主机名后缀
req.request 请求类型 get post head ……
.weight = 7;
内置函数:
req.backend 提供这个请求的原服务器名
beresp.do_gzip 存储前是否压缩
复制代码 代码如下:
当后台服务器上的数据成功被加载到缓存中时调用。req.backend.healthy 提供这个请求的原服务是否正常提供服务
"localhost"; // myself
# Normalize the Host: header
# Don't cache cookies
复制代码 代码如下:
.host_header = "";pass
obj.response由varnish服务器返回的http协议状信息。
"192.168.16.128"/25;
remove beresp.http.Set-Cookie;
.url = "/status.cgi";
set req.backend = foo;
有时候我们的源数据库组织数据比较慢我们可以设定函数如下,这样,每个对象都会被保存在varnish cache中2分钟,这样就可以不用使用户一直等待了,虽然数据不是最新,但 error code [reason]
重启事物。
sub vcl_recv {
resp.http.header 相应的HTTP header.
返回指定错误代码,终止请求。
}
在缓存中查找请求对象,根据是否在缓存中调用vcl_hit or vcl_miss函数
vcl_fetch
如果没有被定义会调用默认的。
error code [reason]
复制代码 代码如下:
backend www {
}
.window = 8;
}
bereq.first_byte_timeout 连接后,得到第一个字节的时间(以秒计算)
error code [reason]
vcl_pipe
Subroutines in VCL do not take arguments, nor do they return values.
restart
.backend = {
在pass模式下被调用,请求被传递到后台服务器,前台与后台直接一次交互,不写日志。
在cache中成功查找到数据会调用这个函数。
是总比用户无法访问强。
pass
Or it can be defined separately and then referenced:: .ttl = 5m; 查找缓存时间
"192.0.2.0"/24; // and everyone on the local network
主机配置
varnish的VCL的配置详解
}"Connection: close";
复制代码 代码如下:
{.port = "http";
sub vcl_recv {
.timeout = 0.3 s;
.initial = 3;
}
if (client.ip ~ local) {
.port = "http";
.list = {
复制代码 代码如下:
} } .between_bytes_timeout = 2s; 在字节与字节之间的等待时间If you have many backends this can simplify the config a lot. deliver
函数调用:
可以调用一下参数终止该函数
if (req.http.host ~ "(?i)example.com") {
req.http.header 相应的HTTP的header。
probe healthcheck {
可以调用一下参数终止该函数
deliver
没有在内存中找到数据的时候调用这个函数,他的目的是是否从后台服务器上取数据,并且是从哪台服务器上取数据。
可以调用hash_data() 把数据添加到hash表中
} elsif (req.http.host ~ "(?i)example.org") {
vcl_pass
.window = 8;
健康检查
}
error code [reason]
变量:
.threshold = 3;
函数形式
! "192.0.2.23"; // except for the dialin router
server.identity varnish服务器标识
.timeout = 0.3 s;
beresp.status 由varnish返回的HTTP状态码
bereq.url
下面的变量在准备反应回给客户端的时候会被使用:
复制代码 代码如下:
}backend www {
req.hash_always_miss 强迫varnish忽略这一请求,直接从元数据库取数据。
resp.response将被返回的HTTP协议状态信息
obj.status 由varnish服务器返回的http协议状态码。
The vcl_recv 会调用一下参数会停止。
HTTP headers can be removed entirely using the remove keyword::
返回错误信息
复制代码 代码如下:
The round-robin director(轮询)bereq.connect_timeout 等待连接源数据库的时间(以秒计算)
deliver
} bereq.request 请求类型 head get post……
但操作系统可以得知这些情况,所以这部份的工作应该交给操作系统处理,这就是 Varnish cache设计架构。
Varnish是一款高性能的开源HTTP加速器,挪威最大的在线报纸 Verdens Gang 使用3台Varnish代替了原来的12台Squid,性能比以前更好。
sub pipe_if_local {
复制代码 代码如下:
req.hash_ignore_busy 在cache lookup时,忽略忙的对象。缓存数据被传递给了客户端,调用这个函数。
beresp.do_esi 解析ESI对象
}
bereq.proto
.port 源服务名或者服务端口号。 The client director 根据客户端(session cookie等)确认访问哪台服务器
set beresp.grace = 2m;
vcl_hit
}
"GET / HTTP/1.1"
director directorname dns {
deliver
}
.probe = healthcheck;
机系统的内存除了主存外,还包括了CPU内的L1、L2,甚至有L3快取。硬盘上也有自己的快取装置,因此Squid Cache自行处理物件替换的架构不可能得知这些情况而做到最佳化,
"192.168.15.0"/24;pass
sub vcl_recv {
backend www {
restart
acl local {
error code [reason]
probe rawprobe {
复制代码 代码如下:
server.hostname varnish服务器主机名bereq.between_bytes_timeout 在两个字节之间的时间(以秒计算) } 在pipe模式下被调用,请求被传递到后台服务器,前台与后台直接多次交互,直到结束不写日志。
.host = "";
resp.proto response给客户端的HTTP 协议版本
目标对象被加载到cache中后,下面的变量可以使用,也就是说在 vcl_hit and vcl_deliver.函数中使用的变量:
.retries = 5;sub vcl_fetch {
now 当前时间
.port = "http";
复制代码 代码如下:
从源数据库中得到数据,在写入cache之前使用的变量,也就是说:在vcl_fetch中使用的变量:
pipe
}
}
变量实例:
}
.weight = 3;
pass
req.can_gzip 客户端是否接受gzip编码
obj.proto 对象检索时使用的http协议。
error code [reason]
return (pipe);
下面的变量在确定一个对象的hash值的时候可用。
可以调用一下参数终止该函数
}
restart
if (req.http.host ~ "(?i)^()?example.com$") {
vcl_deliver
beresp.do_gunzip 存储前是否解压缩
Varnish 的作者Poul-Henning Kamp是FreeBSD的内核开发者之一,他认为现在的计算机比起1975年已经复杂许多。在1975年时,储存媒介只有两种:内存与硬盘。但现在计算
The random director(随即)
.host = "";
fetch
client.ip 客户端IP
}
server.port varnish服务器的端口号
.interval = 60s;
.host = "";
vcl_hash
server.ip varnish服务器的IP
if (client.ip ~ local) {
.threshold = 3;
set req.http.host = "";
req.hash 指定对象的hash key 在读和写的时候会被访问。
bereq.http.header
.request =
call pipe_if_local;
数据被加载到cache中并传递给客户端。调用vcl_deliver
vcl_miss
beresp.response 由varnish返回的 HTTP status信息
obj.hits 对象被访问的大致次数,如果是0,表示对象已经从cache中丢失。
sub vcl_fetch {
下面参数是varnish访问源数据库时使用:
可以调用一下参数终止该函数
}
.backend = b1;
函数样式:其中(?i)是正则表达式中不区分大小写的意思。
.port = "80";
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jq/jc/6967.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
PHP识别相片是否是颠倒的
时间:2020-12-28
-
python编程有哪些ide
时间:2020-12-28
-
python开发工程师是做什么
时间:2020-12-28
-
php构造函数的作用
时间:2020-12-28
-
php怎么跟数据库连接
时间:2020-12-28
-
php实现顺序线性表
时间:2020-12-28
-
Python多重继承中的菱形继
时间:2020-12-28
-
php中break的作用
时间:2020-12-28
热门文章
-
php中常用的正则表达式使用方法
时间:2020-12-25
-
asp与php区别是什么?
时间:2020-12-27
-
PHP识别相片是否是颠倒的,并且重新摆正
时间:2020-12-28
-
Yii授权之基于角色的存取控制 (RBAC)
时间:2020-12-23
-
php的一键安装包有哪些 php环境搭建
时间:2020-12-19
-
php实现对图片对称加解密(适用身份证加
时间:2020-12-25
-
php如何理解面向对象
时间:2020-12-28
-
超详细分析php docker的原理及作用
时间:2020-12-27
-
Python控制Excel实现自动化办公
时间:2020-12-23
-
session的作用是什么
时间:2020-12-25
